<?php
	//$tacoChannels=Array("#ascii","#flood");
	$tacoChannels=Array("#ascii","#flood","#scott");
  if(stristr($buffer,"idea") or stristr($buffer,"taco")){
	if(in_array(strtolower($channel),$tacoChannels)){
      $textToSendA=explode("PRIVMSG $channel :",$buffer);
      $textToSend=" ".$textToSendA[1];
      $textToSend=str_replace("\r","",$textToSend);
      $textToSend=str_replace("\n","",$textToSend);
      if(stristr($buffer,"idea") and stristr($buffer,"taco")){
        if(strpos($buffer,"idea")<strpos($buffer,"taco")){
          $textToSend=preg_replace("/(.*?)idea(.*?)taco(.*?)/i","$1taco$2idea",$textToSend);
        } else {
          $textToSend=preg_replace("/(.*?)taco(.*?)idea(.*?)/i","$1idea$2taco",$textToSend);
        }
      } else if(stristr($buffer,"idea")){
        $textToSend=preg_replace("/(.*?)idea(.*?)/","$1taco$2",$textToSend);
      } else if(stristr($buffer,"taco")) {
        $textToSend=preg_replace("/(.*?)taco(.*?)/","$1idea$2",$textToSend);
      }
      $textToSend=str_ireplace($nickname,$sender,$textToSend);
      $textToSend=preg_replace("/ a (.[aeiou]?)/"," an $1",$textToSend);
      $textToSend=preg_replace("/ an (.[bcdfghijklmnpqrstvwxyz]?)/"," a $1",$textToSend);
      $textToSend=str_replace(Array(" a a"," a e"," a i"," a o", "a u"),Array(" an a"," an e"," an i"," an o", "an u"),$textToSend);
      SendCommand("PRIVMSG $channel :".trim($textToSend));
    }
    sleep(1);
  }
?>